#include "Message.hpp"
#include "lpc/LidarFrame.pb.h"
#include <thread>
#include "TimeUtil.h"
#include "log.h"

TimeUtil::FpsCalc _fps{};

const static char* TAG("SUBTEST");

int main(int argc, char **argv)
{
  message::Context context{"test1"};
  auto _sub = context.createSubscriber<lpc::LidarProtoPointCloud>(
      "tcp://127.0.0.1:58000", [&](const std::shared_ptr<lpc::LidarProtoPointCloud> &msg)
      {
         if (TimeUtil::fps_calc_inc(_fps))
        {
            LOG_I(TAG, "[FPS] Replay lidar {} fps {:.02f}, total fps{:.02f}", msg->lidar_id(), _fps.ins_fps, _fps.avg_fps);
        } });

  while (1)
  {
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  }
}